home *** CD-ROM | disk | FTP | other *** search
/ Die Speccy' 97 / Die Speccy' 97.iso / amiga_system / the_aminet / comm / bbs / s342q07.lha / sysdep.h < prev    next >
C/C++ Source or Header  |  1995-09-17  |  12KB  |  319 lines

  1. /************************************************************************/
  2. /*                              SysDep.H                                */
  3. /*      #include file for all Citadel C files; contains system          */
  4. /*      dependent code.                                                 */
  5. /************************************************************************/
  6. /*
  7. * This is here because Borland International requires all licensees to place
  8. * copyrights on any distributable s/w.  If you are porting C-86 to another
  9. * machine, you should certainly replace the value here with something else.
  10. * A "" is probably acceptable.
  11. */
  12. #define COPYRIGHT " Custom Services 1995"
  13. #include "fctype.h"
  14. #include "stdio.h"
  15. #include "stdlib.h"
  16. #include "string.h"
  17. #include "exec/types.h"
  18. #include "exec/exec.h"
  19. #include "devices/console.h"
  20. #include "devices/keymap.h"
  21. #include "devices/serial.h"
  22. #include "devices/timer.h"
  23. #include "libraries/dos.h"
  24. #include "libraries/dosextens.h"
  25. #include "intuition/intuition.h"
  26. #include "proto/all.h"
  27. #define ANSI_PROTOTYPING
  28. #define IS_MOTOROLA
  29. #define OUTSIDE_EDITOR_SUPPORT
  30. #define SYSTEM_CLOCK
  31. /**
  32.   Special definitions used in message strings
  33. **/
  34. #define VARIANT_NAME    "Citadel-68k"
  35. #define VERSION_NAME  "3.42"
  36. #ifdef _M68020
  37. #define SYSDEP_NAME   "Q07/030"
  38. #else
  39. #define SYSDEP_NAME   "Q07"
  40. #endif
  41. /**
  42.   This structure is used by the BadPeople.sys file processing
  43.   to collect the list of suppressed user/room/system names
  44.  
  45.   A * in the field indicates that the comparision for that
  46.   field is skipped and is a match.
  47.  
  48.   An entry of "* * *" would suppress all messages in all
  49.   rooms for all systems.  This is illegal and will be rejected
  50.   as an error.
  51. **/
  52. struct User_Id
  53.   {
  54.   char *name;   /* suppressed user  ( * == all users ) */
  55.   char *room;   /* suppressed room  ( * == all rooms ) */
  56.   char *system; /* suppressed system( * is all systems ) */
  57.   };
  58.  
  59. #define HORRID_AMIGA_LATTICE_BUG
  60.  
  61. /* these are system debug functions.  */
  62. /* note: some are scattered through out the code */
  63. /*#define NEED_MSG_PEEKING        /* sysop menu items */
  64. /*#define NEED_MSG_LIST           /* sysop menu items */
  65. /*#define NEEDED                    /* sysop menu items */
  66. /*#define EVENT_DEBUG               /* examine events */
  67. /*#define NEED_NET_DEBUG          /* network debug messages */
  68. /*#define NEED_NET_DEBUG_ERRORS   /* network debug messages */
  69. /*#define NEED_TRANS_NET_DEBUG    /* network debug messages */
  70. /*#define TEST_SYS                /* enable debug output */
  71. /*#define NET_DEBUG               /* network debug output */
  72.  
  73. #define sPrintf  sprintf
  74.  
  75. void *special_GetDynamic(unsigned size, char *file, int);
  76. #define GetDynamic(size) special_GetDynamic(size,__FILE__,__LINE__)
  77.  
  78.  
  79. /************************************************************************/
  80. /* These constants, etc. are only for use by SYSDEP.C and other source  */
  81. /* files that contain code that depends on the computer system in use.  */
  82. /* Access is via #define in the appropriate source files.               */
  83. /************************************************************************/
  84. /*
  85. * Required! The following MUST be defined:
  86. *   MSG_SECT_SIZE -- size, in bytes, of a (psuedo) "sector" on disk
  87. *                    for the message file
  88. *   SIZE_SYS_FILE -- longest length, in bytes, of a "system" (i.e., *.SYS,
  89. *                    *.BLB, *.MNU, *.HLP, and net files) file plus 1 (for
  90. *                    the NULL byte.  Variables using this constant are used for
  91. *                    defining a name of a file and then opening it.
  92. *   MSG_NUMBER  -- just what is* a message number
  93. *   SECTOR_ID   -- just what to use to identify a sector
  94. *   AN_UNSIGNED -- an unsigned quantity, very preferably 8 bits
  95. *   ROOM_MSG    -- this needs* to be 16 bits, for a kludge in listRooms()
  96. *   DATA_BLOCK[MSG_SECT_SIZE] -- a block of msg data from disk
  97. *   CRC_TYPE    -- sufficient to hold a XMODEM CRC value
  98. *   SYS_FILE    -- a variable used in makeSysName() that holds the "name" of
  99. *                  a system file (see SIZE_SYS_FILE).  This is passed to
  100. *                  safeopen().  Normally, this would be just a string using
  101. *                  the SIZE_SYS_FILE constant, but I can see situations in
  102. *                  which a struct would be more appropriate.  If you have*
  103. *                  to go with a struct, I suggest making safeopen() a macro
  104. *                  that takes the address of the name (see description of
  105. *                  safeopen for its function).  I.e...
  106. *  #define safeopen(x, y)    ourOpen(&x, y)
  107. *   ROOM_AREA   -- definition of an area attached to a room
  108. *   NET_AREA    -- definition of an area accessible to net functions
  109. *   SYS_AREA    -- definition of an area that may be occupied by a Citadel
  110. *                  system file.
  111. *   MODEM_DATA  -- all necessary modem data for this implementation
  112. *
  113. */
  114. #define MSG_SECT_SIZE   128
  115. #define SIZE_SYS_FILE   128             /* Should be enough             */
  116. #define MAX_FILENAME   24
  117. #define LOCKFILE        "ctdllock.sys"
  118.  
  119. #define ALL_FILES       "*"
  120. #define CACHED_FILES    "*.msg"
  121.  
  122. typedef unsigned long   MSG_NUMBER;       /* Msg number for PClone 32 bits*/
  123. typedef unsigned short  SECTOR_ID;        /* Sector ID -- 16 bits         */
  124. typedef unsigned char   AN_UNSIGNED;
  125. typedef unsigned char   DATA_BLOCK[MSG_SECT_SIZE];
  126. typedef unsigned short  CRC_TYPE;
  127. typedef char            SYS_FILE[SIZE_SYS_FILE];
  128. typedef char            DOMAIN_FILE[40];
  129. typedef unsigned long   MULTI_NET_DATA;
  130. typedef unsigned long   UNS_32;
  131. typedef unsigned short  UNS_16;
  132. struct MenuData
  133.   {
  134.   struct Window *MenuWindow;
  135.   char *MenuCharList;
  136.   struct MsgPort *MenuIOPort;
  137.   struct IOStdReq *MenuIOMsg;
  138.   int DeviceOpen;
  139.  
  140.   };
  141. typedef struct MenuData *MenuId;
  142. #define S_MSG_MASK      0x7fffffffl     /* hi bit, right?       */
  143. #define NO_MENU   NULL
  144. typedef short ROOM_AREA;          /* This might carry the # of the room   */
  145. typedef struct
  146.   {
  147.   char        naDirname[100]; /* Directory anywhere on system         */
  148.  
  149.   }
  150. NET_AREA;
  151. typedef struct
  152.   {
  153.   char  saDirname[64];
  154.  
  155.   }
  156. SYS_AREA;
  157. #define NO_CLOCK        0
  158. #define BUSY_CLOCK      1
  159. #define ALWAYS_CLOCK    2
  160. #define SER_7WIRE       4
  161. struct timePacket
  162.   {
  163.   unsigned long clock[2];
  164.  
  165.   };
  166. typedef struct
  167.   {
  168.   char Editor[15],              /* Outside editor name          */
  169.   EditArea[40],                 /* Where should we do our work? */
  170.   ModemSetup[60],           /* First init of modem.             */
  171.   HiSpeedInit[30];        /* High speed init            */
  172.   short  Clock;
  173.   char LockPort;
  174.   unsigned short ScreenWidth,ScreenHeight,ScreenDepth,Color0,Color1;
  175.   char StartUpEcho,DirectToChip,UnitNumber,DevName[32];
  176.  
  177.   }
  178. DependentData;
  179.  
  180. #define BOOLEAN_FLAG(x)         unsigned x : 1
  181. #define mvToHomeDisk(x)
  182. #define makeVASysName(x, y)     sPrintf(x, "virtual/%s", y)
  183. #define CreateVAName(fn, slot, dir, num) sPrintf(fn, "virtual/%d/%s/%ld", slot, dir, num)
  184. #define ChatEat(c)      c == 0
  185. #define ChatSend(c)     c == 0
  186. #define makeSysName(x, y, z)    sPrintf(x, "%s%s", (z)->saDirname, y)
  187. #define RoomSys(x)      roomBuf.rbArea = x
  188. #define zero_struct(x)     setmem(&x, ( (long)sizeof( x ) & 0x0000ffffL), 0)
  189. #define zero_array(x)      setmem( x, ( (long)sizeof( x ) & 0x0000ffffL), 0)
  190. #define copy_struct(src, dest)  memcpy(&dest, &src, ( (long)sizeof( src )) )
  191. #define copy_array(src, dest)   memcpy(dest,   src, ( (long)sizeof( src )) )
  192. #define copy_ptr(src, dest, s)  memcpy(dest,   src, ( (long)(sizeof( src[0] )) * (long)s) )
  193. #undef  memmove
  194. #define memmove(dest, src, len)  movmem(src, dest, ( (long)len & 0x0000FFFFL) )
  195. #define fastMod outMod          /* temporary */
  196. #define ToTempArea()    MakeTempDir()
  197. extern char TDirBuffer[];
  198. #define KillTempArea()  homeSpace(), rmdir(TDirBuffer)
  199. #define ScreenUser() ScrNewUser()
  200. #define setNetCallBaud(x,y) CitadelBaudRate(minimum(x, cfg.sysBaud),y);
  201. /* sPrintf(temp, "banners\\%s.%d", str, GetSecond()); */
  202. #define makeBanner(x, y, z)     sPrintf(x, "banners/%s.%d", y, z)
  203. #define RedirectName(b, d, f)  sPrintf(b, "%s/%s", d, f);
  204. #define MakeDomainFileName(buffer, Dir, filename) \
  205. sPrintf(buffer, "%s%d/%s", cfg.domainArea.saDirname, Dir, filename)
  206. #define MakeDomainDirectory(x)  DoDomainDirectory(x, FALSE)
  207. #define KillDomainDirectory(x)  DoDomainDirectory(x, TRUE)
  208. #define MakeBioName(buffer, name) \
  209. sPrintf(buffer, "%s%s", cfg.bioArea.saDirname, name)
  210. #define MoveToBioDirectory()    chdir(cfg.bioArea.saDirname);
  211.  
  212.  
  213. #define VirtualCopyFileToFile(fn, vfn)  CitSystem(FALSE, "copy %s %s > nul", fn, vfn)
  214.  
  215. /*
  216.  * These are for handling the net caching stuff.
  217.  */
  218. #define ChangeToCacheDir(x)     chdir(x)
  219. #define NetCacheName(buf, slot, name)       sPrintf(buf, "%snetcache/%d/%s", cfg.netArea.saDirname, slot, name)
  220. #define MakeNetCacheName(buf, slot)       sPrintf(buf, "%snetcache/%d",    cfg.netArea.saDirname, slot)
  221. #define MakeNetCache(buf)                       sPrintf(buf, "%snetcache",       cfg.netArea.saDirname)
  222. #define MakeDeCompressedFilename(fn, Fn)  sPrintf(fn, "%s/%s", TDirBuffer, Fn)
  223. typedef struct {
  224.         char *FileName;
  225.         char *MenuEntry;
  226.         char *DeWork;
  227.         char *IntWork;
  228.         char *CompWork;
  229. } DeCompElement;
  230.  
  231. extern DeCompElement DeComp[];
  232.  
  233. extern DeCompElement DeComp[];
  234. #define GetCompEnglish(CompType)   DeComp[(CompType) - 1].MenuEntry
  235. #define DeCompAvailable(CompType) (DeComp[(CompType) - 1].DeWork != NULL)
  236. #define AnyCompression() (DeComp[LHA_COMP-1].CompWork != NULL || DeComp[ARC_COMP-1].CompWork != NULL || DeComp[ZOO_COMP-1].CompWork != NULL || DeComp[LZH_COMP-1].CompWork != NULL)
  237.  
  238. #define netSetNewArea(fd) realSetSpace((fd)->naDirname)
  239.  
  240. #ifndef CONFIGURE
  241. /* we use our own printf in sysdep3.c */
  242. #undef printf
  243. int printf(const char *format, ...);
  244. #endif
  245. /************************************************************************/
  246. /* These constants, etc. are only for use by SYSDEP.C and other source  */
  247. /* files that contain code that depends on the computer system in use.  */
  248. /* Access is via #define in the appropriate source files.               */
  249. /************************************************************************/
  250. #ifdef CONFIGURE
  251. /**
  252.   parameters for checks in confg
  253. **/
  254. #define HELP            0
  255. #define LOG             1
  256. #define ROOM            2
  257. #define MSG             3
  258. #define MSG2            4
  259. #define NET_STUFF       5
  260. #define CALL            6
  261. #define HOLD            7
  262. #define FLOORA          8
  263. #define DOMAIN_STUFF    9
  264. #define TEMP_AREA      10   /* temp files area                    */
  265. #define QWK2           11   /* BBS Packet name defined            */
  266. #define QWK3           12   /* Files Area Defined                 */
  267. #define QWK4           13   /* Maximum number of rooms at once    */
  268. #define QWK5           14   /* Maximum number of messages at once */
  269. #define BIO_AREA       15   /* biography area defined             */
  270. #define QWK1           16   /* location defined                   */
  271. #define MAX_NEEDED     17   /* total number of parameters checked */
  272. /**
  273.   End of CONFG check parameters
  274. **/
  275. #define I_HANGUP        0
  276. #define I_INIT          1
  277. #define I_CARRDET       2
  278. #define I_SET300        3
  279. #define I_SET1200       4
  280. #define I_SET2400       5
  281. #define I_SETHI         6
  282. #define I_CHECKB        7
  283. #define I_ENABLE        8
  284. #define I_DISABLE       9
  285. #define I_SET4800       10
  286. #define I_SET9600       11
  287. #define I_SET14400      12
  288. #define I_SET19200      13
  289. /* Hmmmmmm.  This stuff shouldn't be here, actually. */
  290. #define R_SH_MARK       "&&"    /* Rather than external char    */
  291. #define NON_LOC_NET     "%%"
  292. #endif
  293. /* Or this.  Fix this someday */
  294. #ifdef V_ADMIN
  295. #define R_SH_MARK       "&&"    /* Rather than external char    */
  296. #define NON_LOC_NET     "%%"
  297. #define LOC_NET         "++"
  298. #endif
  299. #define strCmp          strcmp
  300. #define strLen          strlen
  301. #define toUpper         toupper
  302. #define toLower         tolower
  303. #define strCpy          strcpy
  304. #define strCat          strcat
  305. #define isAlpha         isalpha
  306. #define strnCmp         strncmp
  307. #define isSpace         isspace
  308. #define SEEK_CUR                1
  309. #define NO_STAT
  310. /*#define CTDL_BACKGROUND*/
  311. void Intel16ToMotorola(UNS_16 *);
  312. void Intel32ToMotorola(UNS_32 *);
  313. /*
  314. ** Caller Count routines
  315. */
  316. void Update_Caller_Count(void);
  317. long Get_Call_Count(void);
  318. char *Display_Privledges(void);
  319.